package net.lab0.tools.evo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import net.lab0.tools.evo.iface.Elimination;
import net.lab0.tools.evo.iface.Individual;

public class Truncate<I extends Individual<I>>
implements Elimination<I>
{
    
    @Override
    public List<I> selectIndividuals(List<I> individuals, int count)
    {
        Collections.sort(individuals, new FitnessComparator());
        List<I> ret = new ArrayList<>(count);
        for (int i = 0; i < count; i++)
        {
            ret.add(individuals.get(i));
        }
        return ret;
    }
    
}
